﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace DAO
{
    public class UserDAO
    {
        private ConnectData connData;

        //Ham dung
        public UserDAO()
        {
            connData = new ConnectData();
        }

        public UserDTO LayThongTinUser(string username)
        {
            string sql = "SELECT * FROM nguoidung WHERE idnguoidung = '" + username + "'";
            DataTable tbUser = connData.GetDataTable(sql);
            UserDTO user = new UserDTO();
            if (tbUser.Rows.Count > 0)
            {
                DataRow dtrow = tbUser.Rows[0];
                user.idUser = dtrow["Idnguoidung"].ToString();
                user.passUer = dtrow["passnd"].ToString();
                user.nameUser = dtrow["HoTen"].ToString();
                user.idKindUser = dtrow["idloaind"].ToString();
            }
            else
            {
                user.idUser = ""; //nghia la sai ten dang nhap
            }
            return user;
        }
    }
}
